package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.system.domain.ChatTopics;
import com.hello.system.service.IChatTopicsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 聊天话题分类Controller
 * 
 * @author hello
 * @date 2025-05-15
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/topics")
public class ChatTopicsController extends BaseController
{
    private final IChatTopicsService chatTopicsService;

    /**
     * 查询聊天话题分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ChatTopics chatTopics)
    {
        startPage();
        List<ChatTopics> list = chatTopicsService.selectChatTopicsList(chatTopics);
        return getDataTable(list);
    }

    /**
     * 导出聊天话题分类列表
     */
    @Log(title = "聊天话题分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChatTopics chatTopics)
    {
        List<ChatTopics> list = chatTopicsService.selectChatTopicsList(chatTopics);
        ExcelUtil<ChatTopics> util = new ExcelUtil<ChatTopics>(ChatTopics.class);
        util.exportExcel(response, list, "聊天话题分类数据");
    }

    /**
     * 获取聊天话题分类详细信息
     */
    @GetMapping(value = "/{topicId}")
    public AjaxResult getInfo(@PathVariable("topicId") Long topicId)
    {
        return success(chatTopicsService.selectChatTopicsByTopicId(topicId));
    }

    /**
     * 新增聊天话题分类
     */
    @Log(title = "聊天话题分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChatTopics chatTopics)
    {
        return toAjax(chatTopicsService.insertChatTopics(chatTopics));
    }

    /**
     * 修改聊天话题分类
     */
    @Log(title = "聊天话题分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChatTopics chatTopics)
    {
        return toAjax(chatTopicsService.updateChatTopics(chatTopics));
    }

    /**
     * 删除聊天话题分类
     */
    @Log(title = "聊天话题分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{topicIds}")
    public AjaxResult remove(@PathVariable Long[] topicIds)
    {
        return toAjax(chatTopicsService.deleteChatTopicsByTopicIds(topicIds));
    }
}
